from myblog import db
import datetime


class Article(db.Model):
    __tablename__ = 'b_article'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(200))
    content = db.Column(db.String(20000))
    imgSrc = db.Column(db.String(1000))
    # 创建时间
    create_at = db.Column(db.DateTime, default=datetime.datetime.now)
    # 更新时间
    update_at = db.Column(
        db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)

    def __init__(self, title, content, imgSrc):
        self.title = title
        self.content = content
        self.imgSrc = imgSrc

    def __repr__(self):
        return '<Article %r>' % self.title
